<!-- templates/db_backup_restore.html -->
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库备份与恢复</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/element-plus@2.3.8/dist/index.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/element-plus@2.3.8/dist/index.min.js"></script>

    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#0FC6C2',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                        info: '#86909C'
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                },
            }
        }
    </script>

    <!-- 自定义工具类 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .sidebar-item {
                @apply flex items-center px-4 py-3 text-gray-600 hover:bg-gray-50 hover:text-primary transition-all duration-200;
            }
            .sidebar-item.active {
                @apply bg-primary/10 text-primary border-l-4 border-primary;
            }
            .card-shadow {
                @apply shadow-md hover:shadow-lg transition-shadow duration-300;
            }
        }
    </style>
</head>

<body class="font-inter bg-gray-50 min-h-screen flex flex-col">
<!-- 顶部导航栏 -->
<header class="bg-white shadow-sm">
    <div class="container mx-auto px-4 py-3 flex justify-between items-center">
        <div class="flex items-center space-x-2">
            <i class="fa fa-cubes text-primary text-2xl"></i>
            <h1 class="text-xl font-bold text-gray-800">数据库备份与恢复</h1>
        </div>

        <div class="flex items-center space-x-6">
            <div class="relative">
                <input type="text" placeholder="搜索..."
                       class="pl-10 pr-4 py-2 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary">
                <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
            </div>

            <div class="flex items-center space-x-4">
                <button class="text-gray-600 hover:text-primary transition-colors">
                    <i class="fa fa-bell-o text-xl"></i>
                </button>
                <button class="text-gray-600 hover:text-primary transition-colors">
                    <i class="fa fa-cog text-xl"></i>
                </button>
                <div class="flex items-center space-x-2 cursor-pointer">
                    <img src="https://picsum.photos/200/200" alt="用户头像" class="w-8 h-8 rounded-full object-cover">
                    <span class="text-gray-700">管理员</span>
                </div>
            </div>
        </div>
    </div>
</header>

<div class="flex flex-1 overflow-hidden">
    <!-- 侧边栏导航 -->
    <aside class="w-64 bg-white shadow-md h-[calc(100vh-64px)] overflow-y-auto transition-all duration-300">
        <nav class="py-4">
            <div class="px-4 mb-4">
                <h2 class="text-xs font-semibold text-gray-400 uppercase tracking-wider">主菜单</h2>
            </div>

            <a href="index.html" class="sidebar-item" data-path="index.html">
                <i class="fa fa-tachometer w-5 h-5 mr-3"></i>
                <span>仪表盘</span>
            </a>

            <div class="px-4 mt-6 mb-2">
                <h2 class="text-xs font-semibold text-gray-400 uppercase tracking-wider">数据库管理</h2>
            </div>

            <a href="db_backup_restore.html" class="sidebar-item active" data-path="db_backup_restore.html">
                <i class="fa fa-database w-5 h-5 mr-3"></i>
                <span>数据库备份与恢复</span>
            </a>

            <!-- 可根据需要添加更多侧边栏菜单项 -->
        </nav>
    </aside>

    <!-- 主内容区域 -->
    <main class="flex-1 overflow-y-auto bg-gray-50 p-6">
        <div class="container mx-auto">
            <!-- 页面标题 -->
            <div class="mb-6">
                <h2 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-gray-800">数据库备份与恢复</h2>
                <p class="text-gray-500 mt-1">在这里进行数据库的备份和恢复操作</p>
            </div>

            <!-- 备份与恢复卡片 -->
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6 mb-8">
                <div class="bg-white rounded-xl p-6 card-shadow">
                    <div class="flex justify-between items-start">
                        <div>
                            <p class="text-gray-500 text-sm">数据库备份</p>
                            <h3 class="text-3xl font-bold mt-1 text-gray-800">立即备份</h3>
                            <p class="text-gray-500 mt-2">点击按钮进行数据库备份操作，备份文件将保存到指定位置。</p>
                            <button
                                    class="mt-4 px-6 py-2 bg-primary text-white rounded-md hover:bg-primary/90 transition-colors">
                                <i class="fa fa-download mr-2"></i> 备份数据库
                            </button>
                        </div>
                        <div class="p-4 bg-blue-100 rounded-lg">
                            <i class="fa fa-database text-primary text-2xl"></i>
                        </div>
                    </div>
                </div>

                <div class="bg-white rounded-xl p-6 card-shadow">
                    <div class="flex justify-between items-start">
                        <div>
                            <p class="text-gray-500 text-sm">数据库恢复</p>
                            <h3 class="text-3xl font-bold mt-1 text-gray-800">选择文件恢复</h3>
                            <p class="text-gray-500 mt-2">选择备份文件进行数据库恢复操作，请谨慎操作，恢复后数据将被覆盖。</p>
                            <input type="file" class="mt-4" id="backupFile" accept=".sql">
                            <button
                                    class="mt-4 px-6 py-2 bg-primary text-white rounded-md hover:bg-primary/90 transition-colors">
                                <i class="fa fa-upload mr-2"></i> 恢复数据库
                            </button>
                        </div>
                        <div class="p-4 bg-green-100 rounded-lg">
                            <i class="fa fa-database text-success text-2xl"></i>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 最近备份与恢复记录 -->
            <div class="bg-white rounded-xl p-6 card-shadow">
                <div class="flex justify-between items-center mb-6">
                    <h3 class="font-semibold text-gray-800">最近备份与恢复记录</h3>
                    <button class="text-primary text-sm">查看全部</button>
                </div>
                <div class="overflow-x-auto">
                    <div id="operations-loader" class="py-12 text-center">
                        <div class="inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-primary"></div>
                        <p class="mt-4 text-gray-600">加载操作记录...</p>
                    </div>
                    <table class="w-full hidden" id="recent-operations">
                        <thead>
                        <tr class="border-b border-gray-200">
                            <th class="py-3 text-left text-sm font-medium text-gray-500">操作类型</th>
                            <th class="py-3 text-left text-sm font-medium text-gray-500">操作时间</th>
                            <th class="py-3 text-left text-sm font-medium text-gray-500">操作结果</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!-- 最近操作数据将通过JavaScript动态填充 -->
                        </tbody>
                    </table>
                    <div id="operations-error" class="py-12 text-center hidden">
                        <i class="fa fa-exclamation-circle text-3xl text-warning mb-2"></i>
                        <p class="text-gray-600">加载操作记录失败，请刷新页面重试</p>
                    </div>
                </div>
            </div>
        </div>
    </main>
</div>

<!-- 页脚 -->
<footer class="bg-white py-4 border-t border-gray-200">
    <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
        <p>© 2025 数据库备份与恢复 - 版权所有</p>
    </div>
</footer>

<!-- JavaScript -->
<script>
    // 页面加载完成后初始化
    document.addEventListener('DOMContentLoaded', async () => {
        try {
            // 模拟加载最近操作记录
            setTimeout(() => {
                document.getElementById('operations-loader').classList.add('hidden');
                document.getElementById('recent-operations').classList.remove('hidden');
                // 这里可以添加动态填充最近操作记录的代码
            }, 2000);
        } catch (error) {
            console.error('初始化失败:', error);
            // 显示错误状态
            document.getElementById('operations-loader').classList.add('hidden');
            document.getElementById('operations-error').classList.remove('hidden');
        }
    });
</script>
</body>

</html>